/* rob.vala
 *
 * Copyright (C) 2008  Frederik 'playya' Sdun
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Author:
 *     Frederik 'playya' Sdun <Frederik.Sdun@gmail.com>
 */


using GLib;
using DBus;

namespace Rob
{
    public static const string BASE_OBJ_PATH = "/net/playya/";
    public static const string BUS_NAME = "net.playya.rob";
    [CCode ( cname = "LIBDIR" )]
    public static string libdir;
    [CCode ( cname = "DATADIR" )]
    public static string datadir;
    [CCode ( cname = "SYSCONFDIR" )]
    public static string sysconfdir;
    public static string actionslibdir;
    public static string ruleslibdir;

    public static string actionsconfdir;
    public static string rulesconfdir;


    public static GLib.MainContext maincontext;
    public static GLib.MainLoop mainloop;

    public static DBus.Connection connection;
    public string[] args;

    public void init(ref weak string[] args)
    {
        Rob.maincontext = new GLib.MainContext();
        Rob.mainloop = new GLib.MainLoop( Rob.maincontext, false );
        Rob.connection = DBus.Bus.get( DBus.BusType.SYSTEM );
        Rob.actionslibdir = Path.build_filename( libdir, "rob", "actions" );
        Rob.ruleslibdir = Path.build_filename( libdir, "rob", "rules" );
        Rob.rulesconfdir = Path.build_filename( sysconfdir, "rob", "rules" );
        Rob.actionsconfdir = Path.build_filename( sysconfdir, "rob", "actions" );
        Rob.actionfactory = new Factory(  );
        Rob.actionfactory.load( actionsconfdir );
        Rob.rulefactory = new Factory(  );
        Rob.rulefactory.load( rulesconfdir );
    }
}
